package com.muyu.system.domain.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.muyu.common.core.web.model.QueryModel;
import com.muyu.system.domain.req.SysDictTypeListReq;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 参数配置 分页 模型
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class SysDictTypePageQueryModel extends QueryModel<SysDictTypePageQueryModel> {

    /**
     * 字典名称
     */
    private String dictName;

    /**
     * 字典类型
     */
    private String dictType;

    /**
     * 状态（0正常 1停用）
     */
    private String status;

    /**
     * 开始时间
     */
    private Date beginTime;

    /**
     * 结束时间
     */
    private Date endTime;

    /**
     * 请求参数
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    @TableField(exist = false)
    private Map<String, Object> params;

    public Map<String, Object> getParams () {
        if (params == null) {
            params = new HashMap<>(16);
        }
        return params;
    }

    public void setParams (Map<String, Object> params) {
        this.params = params;
    }

    public static SysDictTypePageQueryModel reqBuild(SysDictTypeListReq sysDictTypeListReq) {
        SysDictTypePageQueryModel sysDictTypePageQueryModel = SysDictTypePageQueryModel.builder()
                .dictName(sysDictTypeListReq.getDictName())
                .dictType(sysDictTypeListReq.getDictType())
                .status(sysDictTypeListReq.getStatus())
                .beginTime(sysDictTypeListReq.getBeginTime())
                .endTime(sysDictTypeListReq.getEndTime())
                .build();
        sysDictTypePageQueryModel.domainBuild(sysDictTypeListReq);
        return sysDictTypePageQueryModel;
    }
}
